package config

import (
	"github.com/spf13/viper"
)

var Conf Yaml

type Yaml struct {
	App struct {
		Port    string `yaml:"port"`
		AppName string `yaml:"appName"`
		LogDir  string `yaml:"logDir"`
	}
	Nodes struct {
		Address []string `yaml:"address"`
	}
}

var vp *viper.Viper

func Init() {
	vp = viper.New()
	vp.AddConfigPath("./config/")
	vp.SetConfigName("pro")
	vp.SetConfigType("yaml")
	err := vp.ReadInConfig()
	if err != nil {
		panic(err)
	}
	//直接整个解析
	err = vp.Unmarshal(&Conf)
	if err != nil {
		panic(err)
	}
}
